<?php
	class sinhviendata
	{
		public function Them($MaSV = "", $TenSV = "",$TenDangNhap = "",$MatKhau = "",$MaLop = "",$MaNganh = "",$NgaySinh = "",$KhoaHoc= "",$MaBoMon = "")
		{
			$sql = "INSERT INTO sinhvien(sv_ma, sv_ten,sv_tendangnhap,sv_matkhau,sv_malop,sv_manganh,sv_ngaysinh,sv_khoahoc,sv_mabomon)
					VALUES('$MaSV', '$TenSV','$TenDangNhap','$MatKhau','$MaLop','$MaNganh','$NgaySinh','$KhoaHoc','$MaBoMon')";
			
			$service = new dataservice();
			return $service->ExecuteNonQuery($sql);
		}
		
		public function CapNhat($MaSV = "", $TenSV = "",$TenDangNhap = "",$MatKhau = "",$MaLop = "",$MaNganh = "",$NgaySinh = "",$KhoaHoc= "",$MaBoMon = "")
		{
			$sql= "UPDATE `sinhvien` SET `sv_ten`='$TenSV',`sv_tendangnhap`='$TenDangNhap',`sv_matkhau`='$MatKhau',`sv_malop`='$MaLop',`sv_manganh`='$MaNganh',`sv_ngaysinh`='$NgaySinh',`sv_khoahoc`='$KhoaHoc',`sv_mabomon`='$sv_mabomon' WHERE `sv_ma`='$MaSV'";
			
			$service = new dataservice();
			return $service->ExecuteNonQuery($sql);
		}
		
		public function Xoa($MaSV = "")
		{
			$sql = "DELETE  FROM sinhvien WHERE sv_ma = '$MaSV'";
			
			$service = new dataservice();
			return $service->ExecuteNonQuery($sql);
		}
		
		public function LayDanhSach($MaSV = "")
		{
			$sql = "SELECT * FROM sinhvien WHERE 1";
			
			if($MaSV != "")
				$sql .= " AND sv_ma = '$MaSV'";
			
			$service = new dataservice();
			return $service->ExecuteQuery($sql);
		}
	}
?>